package cn.duli.xianer.service.impl;

import cn.duli.xianer.dao.GoodsCollectionMapper;
import cn.duli.xianer.pojo.GoodsCollection;
import cn.duli.xianer.pojo.WantGoodsCollection;
import cn.duli.xianer.service.GoodsCollectionService;
import com.github.pagehelper.Page;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class GoodsCollectionServiceImpl implements GoodsCollectionService {

    @Resource
    private GoodsCollectionMapper goodsCollectionMapper;

    @Override
    public void save(GoodsCollection goodsCollection) {
        goodsCollectionMapper.save(goodsCollection);
    }

    @Override
    public GoodsCollection findById(Integer gcId) {
        return goodsCollectionMapper.findById(gcId);
    }

    @Override
    public void deleteById(Integer gcId) {
        goodsCollectionMapper.deleteById(gcId);
    }

    @Override
    public Page<GoodsCollection> findByUserId(Integer gcUid) {
        return goodsCollectionMapper.findByUserId(gcUid);
    }

    @Override
    public boolean isCollection(Integer gcGid, Integer gcUid) {
        // 查询数据库中goods_collection表里面是否有这条收藏信息
        GoodsCollection goodsCollection = goodsCollectionMapper.findByAllId(gcGid, gcUid);
        return goodsCollection == null?false:true;
    }

    @Override
    public GoodsCollection findByAllId(Integer gcGid, Integer gcUid) {
        return goodsCollectionMapper.findByAllId(gcGid, gcUid);
    }


    @Override
    public Page<GoodsCollection> findAll() {
        return goodsCollectionMapper.findAll();
    }
}
